﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace MVVM.Demo.StockProvider
{
    public enum Tick 
    { 
        Up, 
        Down, 
        NoChange 
    }

    public class Quote
    {
        private string _symbol;
        private double _price;
        private int _volume;
        private DateTime _date;
        private Tick _tick;

        public Quote()
        {

        }

        public Quote(string symbol, double price, int volume, DateTime date, Tick tick)
        {
            this._symbol = symbol;
            this._price = price;
            this._volume = volume;
            this._date = date;
            this._tick = tick;
        }

        public string Symbol
        {
            get { return _symbol; }
            set { _symbol = value; }
        }

        public double Price
        {
            get { return _price; }
            set { _price = value; }
        }

        public int Volume
        {
            get { return _volume; }
            set { _volume = value; }
        }

        public DateTime Date
        {
            get { return _date; }
            set { _date = value; }
        }

        public Tick Tick
        {
            get { return _tick; }
            set { _tick = value; }
        }
    }

    //public class Quote
    //{
    //    private StockData _stock;
    //    private decimal _currentPrice;

    //    public Quote(StockData stock)
    //    {
    //        _stock = stock;
    //    }
        
    //    public string Symbol { get { return _stock.Symbol; } }
    //    public DateTime Date { get; set; }
    //    public int Volume { get; set; }
    //    public decimal Price 
    //    { 
    //        get { return _currentPrice; } 
    //        set 
    //        {
    //            _currentPrice = value;

    //            if (_currentPrice < _stock.LastPrice)
    //                Tick = Tick.Down;
    //            else
    //                Tick = Tick.Up;

    //            _stock.SetHighLow(value);
    //        } 
    //    }

    //    public decimal High { get { return _stock.High; } }
    //    public decimal Low { get { return _stock.Low; } }
    //    public decimal Close { get { return _stock.Close; } }
    //    public bool NewHigh { get {return _stock.NewHigh;} }
    //    public bool NewLow { get { return _stock.NewLow; } }

    //    public Tick Tick { get; set; }

    //}

    //public class StockData
    //{
    //    public StockData(string symbol, decimal initialPrice)
    //    {
    //        Symbol = symbol;

    //        this.Close = initialPrice;
    //        this.High = initialPrice;
    //        this.Low = initialPrice;

    //    }

    //    public string Symbol { get; private set; }
    //    public decimal High { get; set; }
    //    public decimal Low { get; set; }
    //    public decimal Close { get; private set; }
    //    public decimal LastPrice { get; set; }

    //    public bool NewHigh { get; private set; }
    //    public bool NewLow { get; private set; }

    //    public void SetHighLow(decimal currentPrice)
    //    {
    //        LastPrice = currentPrice;

    //        NewHigh = false;
    //        NewLow = false;

    //        if (currentPrice > High)
    //        {
    //            High = currentPrice;
    //            NewHigh = true;
    //        }
    //        if (currentPrice < Low)
    //        {
    //            Low = currentPrice;
    //            NewLow = true;
    //        }
    //    }
    //}
}
